<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增仓库类单据')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-receipt-add">
            <div class="form-group">
                <label class="col-sm-3 control-label">单据类型：</label>
                <div class="col-sm-8">
                    <select name="wReceiptType" class="form-control m-b" th:with="type=${@dict.getType('receipt_type')}" th:onchange="generateOrder()" id="wReceiptType">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle">
                    </i> 代码生成请选择字典属性</span>
                </div>
            </div>

            <div class="form-group">    
                <label class="col-sm-3 control-label">单据号：</label>
                <div class="col-sm-8">
                    <input name="wReceiptNumber" class="form-control" type="text" id="wReceiptNumber" readonly>
                </div>
            </div>

            <div class="form-group">    
                <label class="col-sm-3 control-label">工单(生产类单据才会有工单)：</label>
                <div class="col-sm-8">
                    <input name="wWorkOrder" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group" hidden="hidden">
                <label class="col-sm-3 control-label">创建单据日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="wCreateDate" class="form-control" placeholder="yyyy-MM-dd" type="text">
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">补充说明：</label>
                <div class="col-sm-8">
                    <input name="wRemarks" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">物料类型：</label>
                <div class="col-sm-8">
                    <select name="materialType" class="form-control m-b" th:with="type=${@dict.getType('materials_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">数量：</label>
                <div class="col-sm-8">
                    <input name="qty" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group" hidden="hidden">
                <label class="col-sm-3 control-label">创建单据人id：</label>
                <div class="col-sm-8">
                    <input name="wCreatePersonId" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group" hidden="hidden">
                <label class="col-sm-3 control-label">创建人名字：</label>
                <div class="col-sm-8">
                    <input name="wCreatePersonName" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script src="../../static/ruoyi/js/personSelf.js" th:src="@{/ruoyi/js/personSelf.js}"></script>
    <script type="text/javascript">
        var prefix = ctx + "receipt/receipt"
        $("#form-receipt-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-receipt-add').serialize());
            }
        }

        $("input[name='wCreateDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        var typeListId = 1;
        $(function () {
            var nowDate = getNowTime();
            var random = RandomRange(4,4);
            console.log(random);
            var typeListText = $("#wReceiptType option:selected").text();
            var order = createOrder(typeListText);
            // $("#wReceiptNumber").attr("value",'');//清空内容
            $("#wReceiptNumber").val(order);//填充内容
            console.log(order);
        })
        function generateOrder() {//生成单据
            var typeListId =  $("#wReceiptType").val();
            var typeListText = $("#wReceiptType option:selected").text();
            var order = createOrder(typeListText);
            // $("#wReceiptNumber").attr("value",'');//清空内容
            $("#wReceiptNumber").val(order);//填充内容
        }

    </script>
</body>
</html>